package com.kaola.dao.impl;

import java.util.List;

import org.springframework.orm.hibernate3.HibernateTemplate;

import com.kaola.dao.UserDAO;
import com.kaola.pojo.User;

public class UserDAOImpl extends HibernateTemplate implements UserDAO {

	private User user;
	private List<User> users;

	public void create(User user) {
		save(user);
	}

	public User show(int id) {
		return get(User.class, id);
	}

	public List<User> list() {
		return find("from User u");
	}

	public User get(String account) {
		users = find("from User u where u.account=?", account);
		if (users.size() > 0) {
			user = users.get(0);
			return user;
		}
		return null;
	}

	public void modify(User user) {
		update(user);
	}
}
